<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%spus}}".
 *
 * @property int $id
 * @property int|null $copied_by_id
 * @property string $numbering 商品编号
 * @property string $name 商品名
 * @property string|null $desc 商品介绍
 * @property int $keyword_count 关键字数量
 * @property int $sort 排序
 * @property int $status
 * @property string|null $note 备注
 * @property int $created_at
 * @property int $updated_at
 * @property int $deleted_at
 * @property int|null $supplier_id
 * @property int $category_id
 * @property int|null $cate_root_id 分类根
 * @property int $is_virtual 是否虚拟商品
 * @property int $is_second_hand 是否二手
 * @property int $is_put_on_sale 是否上架
 * @property int $is_auto_put_on_sale 是否自动上架
 * @property int $is_auto_put_off_sale 是否自动下架
 * @property int|null $put_on_sale_begin
 * @property int|null $put_on_sale_end
 * @property float $freight_price 运费
 * @property int $append_remote_freight_province_count 运费追加省数量
 * @property int $is_present_insurance 是否赠送运费险
 * @property int $inventory 总库存数
 * @property int|null $created_by_adminer
 * @property int|null $updated_by_adminer
 * @property int|null $created_by_supplier
 * @property int|null $updated_by_supplier
 * @property int|null $created_by_shop_user
 * @property int|null $updated_by_shop_user
 */
class Spus extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%spus}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['copied_by_id', 'numbering', 'name', 'desc', 'keyword_count', 'sort', 'status', 'note', 'created_at', 'updated_at', 'deleted_at', 'supplier_id', 'category_id', 'cate_root_id', 'is_virtual', 'is_second_hand', 'is_put_on_sale', 'is_auto_put_on_sale', 'is_auto_put_off_sale', 'put_on_sale_begin', 'put_on_sale_end', 'freight_price', 'append_remote_freight_province_count', 'is_present_insurance', 'inventory', 'created_by_adminer', 'updated_by_adminer', 'created_by_supplier', 'updated_by_supplier', 'created_by_shop_user', 'updated_by_shop_user'], 'trim'],
            [['copied_by_id', 'keyword_count', 'sort', 'status', 'created_at', 'updated_at', 'deleted_at', 'supplier_id', 'category_id', 'cate_root_id', 'is_virtual', 'is_second_hand', 'is_put_on_sale', 'is_auto_put_on_sale', 'is_auto_put_off_sale', 'put_on_sale_begin', 'put_on_sale_end', 'append_remote_freight_province_count', 'is_present_insurance', 'inventory', 'created_by_adminer', 'updated_by_adminer', 'created_by_supplier', 'updated_by_supplier', 'created_by_shop_user', 'updated_by_shop_user'], 'integer'],
            [['numbering', 'name', 'created_at', 'updated_at', 'category_id'], 'required'],
            [['desc', 'note'], 'string'],
            [['freight_price'], 'number'],
            [['numbering'], 'string', 'max' => 48],
            [['name'], 'string', 'max' => 180],
            [['copied_by_id', 'desc', 'note', 'supplier_id', 'cate_root_id', 'put_on_sale_begin', 'put_on_sale_end', 'created_by_adminer', 'updated_by_adminer', 'created_by_supplier', 'updated_by_supplier', 'created_by_shop_user', 'updated_by_shop_user'], 'default', 'value' => null],
            [['keyword_count', 'sort', 'deleted_at', 'append_remote_freight_province_count', 'inventory'], 'default', 'value' => 0],
            [['status'], 'default', 'value' => 200],
            [['is_virtual', 'is_second_hand', 'is_put_on_sale', 'is_auto_put_on_sale', 'is_auto_put_off_sale', 'is_present_insurance'], 'default', 'value' => 2],
            [['freight_price'], 'default', 'value' => 0.00],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'copied_by_id' => Yii::t('app', 'Copied By ID'),
            'numbering' => Yii::t('app', '商品编号'),
            'name' => Yii::t('app', '商品名'),
            'desc' => Yii::t('app', '商品介绍'),
            'keyword_count' => Yii::t('app', '关键字数量'),
            'sort' => Yii::t('app', '排序'),
            'status' => Yii::t('app', 'Status'),
            'note' => Yii::t('app', '备注'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'deleted_at' => Yii::t('app', 'Deleted At'),
            'supplier_id' => Yii::t('app', 'Supplier ID'),
            'category_id' => Yii::t('app', 'Category ID'),
            'cate_root_id' => Yii::t('app', '分类根'),
            'is_virtual' => Yii::t('app', '是否虚拟商品'),
            'is_second_hand' => Yii::t('app', '是否二手'),
            'is_put_on_sale' => Yii::t('app', '是否上架'),
            'is_auto_put_on_sale' => Yii::t('app', '是否自动上架'),
            'is_auto_put_off_sale' => Yii::t('app', '是否自动下架'),
            'put_on_sale_begin' => Yii::t('app', 'Put On Sale Begin'),
            'put_on_sale_end' => Yii::t('app', 'Put On Sale End'),
            'freight_price' => Yii::t('app', '运费'),
            'append_remote_freight_province_count' => Yii::t('app', '运费追加省数量'),
            'is_present_insurance' => Yii::t('app', '是否赠送运费险'),
            'inventory' => Yii::t('app', '总库存数'),
            'created_by_adminer' => Yii::t('app', 'Created By Adminer'),
            'updated_by_adminer' => Yii::t('app', 'Updated By Adminer'),
            'created_by_supplier' => Yii::t('app', 'Created By Supplier'),
            'updated_by_supplier' => Yii::t('app', 'Updated By Supplier'),
            'created_by_shop_user' => Yii::t('app', 'Created By Shop User'),
            'updated_by_shop_user' => Yii::t('app', 'Updated By Shop User'),
        ];
    }
}
